package Controller;

        import repository.CheckRepository;
        import repository.DeleteRepository;
        import repository.DeleteUserRepository;
        import repository.ReleaseRepository;

        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import javax.servlet.http.HttpSession;
        import java.io.IOException;
        import java.io.PrintWriter;
        import java.sql.SQLException;

@WebServlet(name = "DeleteUserHtml")
public class DeleteUser extends HttpServlet{
    private static final long serialVersionUID = 1L;


    public DeleteUser(){
        super();
        //TODO Auto-generated constructor stub
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{
        response.setContentType("text/html;charset=UTF-8");

        PrintWriter out = response.getWriter();
        String account = request.getParameter("account");


        System.out.println(account);

        DeleteUserRepository deleteUserRepository = new DeleteUserRepository();
        boolean release = false;
        try {
            release = deleteUserRepository.ChangeAdmin(account);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        System.out.println("delete="+release);

    }
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
